package com.woniuxy.enjoylife.controller;

import com.woniuxy.enjoylife.service.FileService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/file")
public class FileController {
    @Resource
    private FileService fileService;

    @RequestMapping("/uploadImage")
    public String uploadImage(@RequestBody MultipartFile file){
        return fileService.uploadImage(file);
    }

    @RequestMapping("/images/{name}")
    public void getImage(@PathVariable("name") String name , HttpServletResponse response){
        fileService.getImage(name,response);
    }


}
